<template>
  <div id="contsainer"></div>
</template>
<script>
export default {
  data() {
    return {
      viewer: null
    }
  },
  mounted() {
    this.initCesium()
    this.addGridMaterial(this.viewer)
  },
  methods: {
    initCesium() {
      this.viewer = new Cesium.Viewer('contsainer', {
        animation: false,
        baseLayerPicker: false,
        fullscreenButton: false,
        geocoder: false,
        homeButton: false,
        infoBox: false,
        sceneModePicker: false,
        navigationHelpButton: false,
        scene3DOnly: true,
        timeline: false,
        selectionIndicator: false, //是否显示选取指示器组件
        shouldAnimate: false, //自动播放动画控件
        shadows: true, //是否显示光照投射的阴影
        terrainShadows: Cesium.ShadowMode.RECEIVE_ONLY, //地质接收阴影
        sceneMode: Cesium.SceneMode.SCENE3D
      })
      this.viewer._cesiumWidget._creditContainer.style.display = 'none' //	去除版权信息
    },
    addGridMaterial(viewer) {
      let entity = viewer.entities.add({
        name: 'plane',
        position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
        plane: {
          plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 100000.0), //指定平面的法线和距离
          dimensions: new Cesium.Cartesian2(400000.0, 300000.0), //指定平面的宽度和高度。
          material: new Cesium.GridMaterialProperty({
            color: Cesium.Color.YELLOW, //网格颜色
            cellAlpha: 0.2, //单元格透明度
            lineCount: new Cesium.Cartesian2(8, 8), // 行列个数
            lineThickness: new Cesium.Cartesian2(2.0, 2.0), //线粗细
            lineOffset: new Cesium.Cartesian2(2.0, 2.0) // 线偏移
          })
        }
      })
      console.log(entity.plane.material)
      viewer.zoomTo(viewer.entities)
    }
  }
}
</script>
<style scoped>
#contsainer {
  height: 100%;
  width: 100%;
  background-color: red;
}
</style>
